package com.ssy.lingxi.member.merchant.repository;

import com.ssy.lingxi.member.merchant.entity.MemberProcessRuleDO;
import com.ssy.lingxi.member.merchant.entity.RoleDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 会员管理流程规则配置Jpa仓库
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-14
 */
@Repository
public interface MemberProcessRuleRepository extends JpaRepository<MemberProcessRuleDO, Long>, JpaSpecificationExecutor<MemberProcessRuleDO> {

    boolean existsByMemberIdAndRoleIdAndSubRole(Long memberId, Long roleId, RoleDO subRole);

    boolean existsByMemberIdAndRoleIdAndSubRoleAndIdNot(Long memberId, Long roleId, RoleDO subRole, Long id);

    MemberProcessRuleDO findFirstByMemberIdAndRoleIdAndSubRoleAndStatus(Long memberId, Long roleId, RoleDO subRole, Integer status);

    boolean existsByMemberIdAndRoleIdAndSubRoleInAndBaseDepositoryProcessIdGreaterThanAndConfigsIsNotNull(Long memberId, Long roleId, List<RoleDO> subRoles, Long processId);
}
